use std::{io::Read, net::TcpListener};

use hiecho_web::ThreadPool;

fn main() {
    let server = TcpListener::bind("127.0.0.1:80").unwrap();
    println!("server is starting \r\n {}", "http://127.0.0.1:80");
    let thread_pool = ThreadPool::new(5);
    server.incoming().take(5).into_iter().for_each(|f| {
        let mut client = f.unwrap();
        thread_pool.execable(move || {
            let mut buffer = [0; 1024];
            client.read(&mut buffer[..]).unwrap();
            println!(
                "---{:?}----{}",
                client,
                String::from_utf8_lossy(&buffer[..])
            );
        })
    });
}
